<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>系统锁定页面</title>
    <link href="../../lib/nifty/css/bootstrap.min.css" rel="stylesheet">
    <link href="../../lib/nifty/css/nifty.min.css" rel="stylesheet">
    <link href="../../lib/nifty/css/demo/nifty-demo-icons.min.css" rel="stylesheet">
    <link href="../../lib/nifty/css/demo/nifty-demo.min.css" rel="stylesheet">
    <link rel="stylesheet" href="../../lib/nifty/plugins/layer/skin/default/layer.css">
    <link href="../../lib/nifty/plugins/pace/pace.min.css" rel="stylesheet">
    <script src="../../lib/nifty/plugins/pace/pace.min.js"></script>
    <script src="../../lib/nifty/js/jquery-2.2.4.min.js"></script>
    <script src="../../lib/nifty/js/bootstrap.min.js"></script>
    <script src="../../lib/nifty/js/nifty.min.js"></script>
    <script src="../../lib/nifty/plugins/layer/layer.js"></script>
    <script src="../../lib/nifty/plugins/vue/vue.min.js"></script>
    <script src="../../lib/nifty/js/app.config.js"></script>
</head>
<body>
<div id="container" class="cls-container">

    <!-- BACKGROUND IMAGE -->
    <!--===================================================-->
    <div id="bg-overlay"></div>

    <!-- LOCK SCREEN -->
    <!--===================================================-->
    <div class="cls-content">
        <div class="cls-content-sm panel">
            <div class="panel-body">
                <div class="mar-ver pad-btm">
                    <h3 class="h4 mar-no">{{user.user_name}}</h3>
                    <span class="text-muted">{{user.user_code}}</span>
                </div>
                <div class="pad-btm mar-btm">
                    <img alt="Profile Picture" class="img-lg img-circle img-border-light" src="../../lib/nifty/img/profile-photos/1.png">
                </div>
                <p>请输入密码以解锁屏幕！</p>
                    <div class="form-group">
                        <input type="password" class="form-control" placeholder="请输入密码" v-model="user.password">
                    </div>
                    <div class="form-group text-right">
                        <button class="btn btn-block btn-success" type="button" onclick="$.fn.login();">登录</button>
                    </div>
                <div class="pad-ver">
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var user = null;
    var index = parent.layer.getFrameIndex(window.name);
    $(document).ready(function () {
        user = $.fn.logcheck();
        if(!user){
            return false;
        }

        vm = new Vue({
            el:'#container',
            data: {
                user : {
                    user_code : '',
                    user_name : '',
                    password:''
                }
            },
            methods: {

            },
            created: function () {
                if(user){
                   this.user.user_code = user.userCode;
                   this.user.user_name = user.userName;
                }
                //$.fn.logout();
        });

    });
    $.fn.extend({
        login:function () {
            $.ajax({
                url: app.rootPath+'/sys_login/login',
                type: 'POST',
                dataType: 'json',
                data:{
                    usercode : vm.$data.user.user_code,
                    password : vm.$data.user.password
                },
                async :  false,
                success:function(data) {
                    if(data.success){
                        parent.layer.closeAll();
                    }else{
                        layer.alert(data.message, {icon:5});
                    }
                }
            });
        },
        logout:function () {
            $.post(app.rootPath+'/sys_login/logout', function(data){
                if(data.success){
                }else{
                    layer.alert(data.message,{icon: 2,title:'操作提示'});
                }
            });
        },
        relogin:function(){
            parent.layer.closeAll();
            window.open("sys-login.html");
        },
        logcheck:function(){
            var CurrentUser;
            $.ajax({
                url: app.rootPath+"/sys_login/logcheck",
                method: 'GET',
                async :  false,//同步请求
                success: function (data) {
                    if(data.success){
                        CurrentUser=data.rows;
                    }else{
                        window.location.href='sys-login.html';
                    }
                }
            });
            return CurrentUser;
        }
    });
</script>
</body>
</html>
